package cn.itcast.service;

import cn.itcast.mapper.UserMapper;
import cn.itcast.pojo.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * Author: Saka
 * Date: 2019/1/9
 * Time: 15:18
 */
@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;
    Logger logger = LoggerFactory.getLogger(UserService.class);
    public User queryByID(Long id) {
        int time = (int) (Math.random() * 2000);
        try {
            Thread.sleep(time);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        User user = this.userMapper.selectByPrimaryKey(id);
        logger.info("本次查询id为{},耗时为{}",id,time);
        return user;
    }
}
